﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BLL;
using Model;
using Ysb.Components;
public partial class Admin_Admin_Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!Page.IsPostBack)
        {
            DataLoad();
        }
    }
    private void DataLoad()
    {


    }
    protected void okbtn_Click(object sender, EventArgs e)
    {
        if (Session["Code"] == null)
        {
            Response.Redirect(Request.Url.ToString());
        }
        if (yztxt.Text.Trim().ToLower() == Session["Code"].ToString())
        {



            AdminLoginUser user = new AdminLoginUser();
            user.LoginName = loginnametxt.Text.Trim();
            user.PassWord = StrHelper.EncryptPassword(passtxt.Text.Trim(), StrHelper.PasswordType.MD5);


            user = new AdminLoginUserService().AdminLoginUserLogin(user);
            if (user == null)
            {

                Jscript.AjaxAlert(this, "请检查 登录名、密码是否正确！");
            }
            else
            {
                Session["ALogin"] = 1;
                Session["Lname"] = user.LoginName;
                Session["uid"] = user.ID;
                Session["UserName"] = user.UserName;
                Session["Rights"] = user.Right;

                Session.Remove("Code");
                Response.Redirect("Admin_Main2.aspx");
            }

        }
        else
        {
            Jscript.AjaxAlert(this, "验证码输入错误");//, "Admin_Login.aspx"
        }

    }
}
